/***************************************************************************\
 * Copyright (C) by Keio University
 * Texture.hpp created in 09 2011.
 * Mail : fdesorbi@hvrl.ics.keio.ac.jp
 *
 * Texture.cpp is part of the HVRL Library.
 *
 * The HVRL Engine Library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * The HVRL Engine Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
\***************************************************************************/

#ifndef __HVRL_TEXTURE_HPP__
#define __HVRL_TEXTURE_HPP__

#include <glm/glm.hpp>
#include <sstream>
#include "hvrl/common/Common.hpp"

namespace hvrl
{

    static std::string matrixToString(const glm::mat4& mat)
    {
        std::ostringstream os;
        for(unsigned int i = 0; i < 4; ++i)
        {
            for(unsigned int j = 0; j < 4; ++j)
            {
                os << mat[i][j] << " ";
            }
            os << std::endl;
        }
        return os.str();
    }

    template <typename T, size_t size>
    static std::string matrixToString(T (&mat)[size])
    {
        unsigned int maxi = 1;
        unsigned int maxj = static_cast<unsigned int>(size);
        if(isPowerOfTwo(maxj))
        {
            maxj = maxi = fastSqrtui(maxj);
        }
        std::ostringstream os;
        for(unsigned int i = 0; i < maxi; ++i)
        {
            for(unsigned int j = 0; j < maxj; ++j)
            {
                os << mat[i*4+j] << " ";
            }
            os << std::endl;
        }
        return os.str();
    }

}

#endif
